<template>
  <div style="background-color: #f8f8f8">
    <div class="log-bg">
      <div class="login-container banner_dh">
        <el-form ref="loginForm" :model="loginForm" :rules="loginRules" class="login-form" auto-complete="on" label-position="left">
          <div class="title-container">
            <h3 class="title">企业登录</h3>
          </div>
          <el-form-item prop="username">
            <span class="svg-container">
              <svg-icon icon-class="user" />
            </span>
            <el-input
              ref="username"
              v-model="loginForm.username"
              placeholder="输入邮箱"
              name="username"
              type="text"
              tabindex="1"
            />
          </el-form-item>
          <el-form-item prop="password">
            <span class="svg-container">
              <svg-icon icon-class="password" />
            </span>
            <el-input
              :key="passwordType"
              ref="password"
              v-model="loginForm.password"
              type="password"
              placeholder="请输入密码"
              name="password"
              tabindex="2"
              auto-complete="on"
              @keyup.enter.native="handleLogin"
            />
            <span class="show-pwd" @click="showPwd">
              <svg-icon :icon-class="passwordType === 'password' ? 'eye' : 'eye-open'" />
            </span>
          </el-form-item>
          <el-button :loading="loading" type="success" style="width:45%;float: left;margin: 0 2%" @click.native.prevent="handleLogin">用户登录</el-button>
          <div class="tips" style="color:#495d64;line-height:40px;text-align:center;margin-top:10px;">
            <span style="font-size: 14px;color: #87023f;cursor: pointer;margin-right: 20px" @click="forgetPwd">忘记密码?</span>
          </div>
        </el-form>
      </div>
    </div>
    <div style="width: 1200px; margin: 0 auto;">
      <div style="display: flex; padding: 115px 0 80px 0;">
        <el-card shadow="always" class="home-card">
          <div style="text-align: center; font-size: 22px; font-weight: 600;">专业化</div>
          <div style="padding: 14px 0; line-height: 25px;font-size: 14px">专注核心业务，具有专业化生产服务和协作配套的能力，为大企业、大项目和产业链提供零部件、元器件、配套产品和配套服务。</div>
        </el-card>
        <el-card shadow="always" class="home-card">
          <div style="text-align: center; font-size: 22px; font-weight: 600;">精细化</div>
          <div style="padding: 14px 0; line-height: 25px;font-size: 14px">具备精细化生产、精细化管理、精细化服务，以美誉度高、性价比好、品质精良的产品和服务在细分市场中占据优势。</div>
        </el-card>
        <el-card shadow="always" class="home-card">
          <div style="text-align: center; font-size: 22px; font-weight: 600;">特色化</div>
          <div style="padding: 14px 0; line-height: 25px;font-size: 14px">采用独特的工艺、技术、配方或特殊原料进行研制生产，产品或服务 具有独特性、独有性、独家性特点，掌握自主知识产权。</div>
        </el-card>
        <el-card shadow="always" class="home-card">
          <div style="text-align: center; font-size: 22px; font-weight: 600;">新颖化</div>
          <div style="padding: 14px 0; line-height: 25px;font-size: 14px">开展技术、 管理和商业模式创新通过行业的交叉融合提供新的产品或服务，具有“新技术、新产业、新业态新模式”等四新经济发展特征。</div>
        </el-card>
        <div style="padding: 0px">
          <img
            src="../../assets/img/zjtx.png"
            height="220"
            width="280"
          >
        </div>
      </div>
    </div>
    <div class="col-tital"> <div class="col-tital-main">政 策 <span style="color: #0a76a4">咨 讯</span></div><div class="col-tital-minor">汇集政策热点 详实政策解读</div></div>
    <div class="col-con">
      <div class="col-con-left">
        <div class="col-con-left-tital">
          <img src="../../assets/img/shutiao.png" class="col-con-tital-tiao">
          <div class="col-con-left-tital-main">专精特新</div>
          <router-link to="/" target="_blank">
            <div class="col-con-left-tital-min">更多></div>
          </router-link>
        </div>

        <ul>
          <li>
            <router-link to="/news_2024100901" target="_blank">
              <div class="col-con-li-title">关于公布2024年第三批河北省创新型中小企业名单的通知</div><div class="col-con-li-title-r"><el-tag type="warning" size="medium">专精特新</el-tag></div>
              <div class="col-com-li-time">发布时间:2024-10-09</div>
            </router-link>
          </li>
          <li>
            <router-link to="/news_2024100902" target="_blank">
              <div class="col-con-li-title">湖北十堰市：关于开展第五批创新型中小企业培育工作的通知</div><div class="col-con-li-title-r"><el-tag type="warning" size="medium">专精特新</el-tag></div>
              <div class="col-com-li-time">发布时间:2024-10-09</div>
            </router-link>
          </li>
          <li>
            <router-link to="/news_2024100903" target="_blank">
              <div class="col-con-li-title">关于开展北京市第一批第二年专精特新 “小巨人”企业高质量发展项目绩效考核工作的通知</div><div class="col-con-li-title-r"><el-tag type="warning" size="medium">专精特新</el-tag></div>
              <div class="col-com-li-time">发布时间:2024-10-09</div>
            </router-link>
          </li>
        </ul>

      </div>
      <div class="col-con-right">
        <div class="col-con-left-tital">
          <img src="../../assets/img/shutiao.png" class="col-con-tital-tiao">
          <div class="col-con-left-tital-main">热点政策</div>
          <router-link to="/" target="_blank">
            <div class="col-con-left-tital-min">更多></div>
          </router-link>
        </div>

        <ul>
          <li>
            <router-link to="/news_2024101001" target="_blank"><div class="col-con-li-title">中共中央办公厅 国务院办公厅关于加快公共数据资源开发利用的意见</div><div class="col-con-li-title-r"><el-tag type="info" size="medium">热点政策</el-tag></div>
              <div class="col-com-li-time">发布时间:2024-10-10</div>
            </router-link>
          </li>
          <li>
            <router-link to="/news_2024101002" target="_blank">
              <div class="col-con-li-title">关于印发《国家数据标准体系建设指南》的通知</div><div class="col-con-li-title-r"><el-tag type="info" size="medium">热点政策</el-tag></div>
              <div class="col-com-li-time">发布时间:2024-10-10</div>
            </router-link>
          </li>
          <li>
            <router-link to="/news_2024101003" target="_blank">
              <div class="col-con-li-title">网络数据安全管理条例</div><div class="col-con-li-title-r"><el-tag type="info" size="medium">热点政策</el-tag></div>
              <div class="col-com-li-time">发布时间:2024-10-10</div>
            </router-link>
          </li>
        </ul>

      </div>
    </div>
    <div class="col-tital" s> <div class="col-tital-main">服 务 <span style="color: #0a76a4">入 口</span></div><div class="col-tital-minor">打造线上线下一站式服务</div></div>
    <div class="col-con" style="height: 130px">
      <div class="col-con-ser-img">
        <a href="http://xxcyqiye.miit.gov.cn/" target="_blank">
          <img src="../../assets/img/1.png">
        </a>
        <a href="http://ucenter.miit.gov.cn/login.jsp?toUrl=http%3A%2F%2Fzjtx.miit.gov.cn%2Fqyxx%2Fgotoszhsp" target="_blank">
          <img src="../../assets/img/2.png">
        </a>
        <a href="https://baosong.miit.gov.cn/ScaleTest" target="_blank">
          <img
            src="../../assets/img/3.png"
            height="158"
            width="279"
          ></a>
        <a href="/">
          <img
            src="../../assets/img/4.png"
            height="158"
            width="279"
          ></a>
        <a href="http://www.cnzx315.com/" target="_blank">
          <img
            src="../../assets/img/5.png"
            height="158"
            width="279"
          >
        </a>
      </div>
    </div>
    <div class="col-con" style="height: 110px"><img src="../../assets/img/6.png" style="width: 1200px;height: 115px"></div>
    <div class="col-con" style="height: 12px">
      <div class="" style="margin-left: 20px">
        <img src="../../assets/img/shutiao.png" class="col-con-tital-tiao">
        <div class="col-con-left-tital-main">友情链接</div>
      </div>
    </div>
    <div class="col-con" style="height: 300px;background: #ffffff;">
      <div class="col-yqlj">
        <a href="https://www.miit.gov.cn" target="_blank">
          <img src="../../assets/img/y1.png" height="109" width="273">
        </a>
        <a href="https://www.stats.gov.cn/" target="_blank">
          <img src="../../assets/img/y2.png" height="109" width="273">
        </a>
        <a href="http://365trade.com.cn/" target="_blank">
          <img src="../../assets/img/y3.png" height="109" width="273">
        </a>
        <a href="https://www.bfhg.com.cn/" target="_blank">
          <img src="../../assets/img/y4.png" height="109" width="273">
        </a>
        <a href="https://www.inspur.com/" target="_blank">
          <img src="../../assets/img/y5.png" height="109" width="273">
        </a>
        <a href="https://www.spacechina.com/" target="_blank">
          <img src="../../assets/img/y6.png" height="109" width="273">
        </a>
        <a href="http://www.xlshuju.cn/" target="_blank">
          <img src="../../assets/img/y7.jpg" height="109" width="273">
        </a>
        <a href="http://www.shuzihua.xlshuju.cn/" target="_blank">
          <img src="../../assets/img/y8.png" height="109" width="273">
        </a>
      </div>
    </div>

  </div>
</template>
<script>
import { login } from '@/api/user'
import { setToken, setUsername } from '@/utils/auth'
import { encryptDes } from '@/utils/des'

export default {
  name: 'Home',
  data() {
    const validateUsername = (rule, value, callback) => {
      if (!value) {
        callback(new Error('请填写用户名'))
      } else {
        callback()
      }
    }
    const validatePassword = (rule, value, callback) => {
      if (value.length < 3) {
        callback(new Error('请填写密码'))
      } else {
        callback()
      }
    }
    return {
      country: [],
      place: [],
      userData: '',
      loginForm: {
        username: '',
        password: ''
      },
      userInfo: {
        type: '',
        username: '',
        name: ''
      },
      loginRules: {
        username: [{ required: true, trigger: 'blur', validator: validateUsername }],
        password: [{ required: true, trigger: 'blur', validator: validatePassword }]
      },
      loading: false,
      passwordType: 'password',
      redirect: undefined
    }
  },
  created() {
  },
  methods: {
    forgetPwd() {
      this.$router.push({ path: '/forget' })
    },
    showPwd() {
      if (this.passwordType === 'password') {
        this.passwordType = ''
      } else {
        this.passwordType = 'password'
      }
      this.$nextTick(() => {
        this.$refs.password.focus()
      })
    },
    handleLogin() {
      const that = this
      this.loading = true
      this.$refs.loginForm.validate(valid => {
        if (valid) {
          const obj = { ...this.loginForm }
          const username = encryptDes(obj.username)
          const password = encryptDes(obj.password)
          login({ username: username, password: password }).then(response => {
            if (response.result === 1) {
              setToken(response.data.token)
              setUsername(response.data.username)
              this.loading = false
              that.$router.push('/console')
            } else {
              this.loading = false
              this.$message({
                message: response.msg, type: 'error'
              })
            }
          }).catch(() => {
            this.loading = false
          })
        } else {
          this.loading = false
        }
      })
    }
  }
}
</script>
<style lang="scss" scoped>
$bg:#fff;
$light_gray:#fff;
$cursor: #aaa;

.log-bg {
  background: url(../../assets/img/login_bg.jpg) center center no-repeat;
  background-size: 100% 100%;
  width: 100%;
  min-height: 500px;
  height: 500px;
}
.home-card {
  width: 240px;
  height: 215px;
  border-radius: 5px;
  margin-right: 20px;
  background-color: #3A71A8;
  color: #ffffff;
}

@supports (-webkit-mask: none) and (not (cater-color: $cursor)) {
  .login-container .el-input input {
    color: $cursor;
  }
}
/* reset element-ui css */
.login-container {
  .el-input {
    display: inline-block;
    height: 47px;
    width: 85%;
    input {
      background: #fff;
      border: 0;
      -webkit-appearance: none;
      //padding: 12px 5px 12px 15px;
      margin: 4px 4px;
      color: #888888;
      height: 37px;
      caret-color: $cursor;
      border-radius: 4px;
      &:-webkit-autofill {
        box-shadow: 0 0 0 1000px inset !important;
        -webkit-text-fill-color: $cursor !important;
      }
    }
  }
  .el-form-item {
    border: 1px solid rgba(255, 255, 255, 0.1);
    background: rgba(0, 0, 0, 0.1);
    border-radius: 5px;
    color: #454545;
  }
}
</style>
<style lang="scss" scoped>
$dark_gray:#889aa4;
$light_gray:#eee;

.login-container {
  min-height: 100%;
  width: 100%;
  overflow: hidden;
  .diBox{
    width: 100%;
    position: relative;
    bottom:0;left: 0;
    .foot_text{
      width: 1200px;
      margin:0 auto;
    }
  }
  .login-form {
    position: relative;
    width: 520px;
    max-width: 100%;
    padding: 0 35px 0;
    margin: 3% 7% 0 53%;
    overflow: hidden;
    background-color: #f0f7fd;
    box-shadow: 0 0 20px 5px #60b5da;

  }
  .tips {
    font-size: 14px;
    color: #fff;
    margin-bottom: 10px;

    span {
      &:first-of-type {
        margin-right: 16px;
      }
    }
  }
  .svg-container {
    padding: 6px 5px 6px 15px;
    color: $dark_gray;
    vertical-align: middle;
    width: 30px;
    display: inline-block;
  }
  .title-container {
    position: relative;
    .title {
      font-size: 26px;
      color: #495d64;
      margin: 20px auto 20px auto;
      text-align: center;
      font-weight: bold;
    }
  }
  .show-pwd {
    position: absolute;
    right: 10px;
    top: 7px;
    font-size: 16px;
    color: $dark_gray;
    cursor: pointer;
    user-select: none;
  }
}
.banner_dh{
  width: 100%;
  /*height: 650px;*/
  min-width: 1200px;
  position: relative;
  z-index: 1;
  display: flex;
  flex-flow: column;
  justify-content: space-between;
}
.col-tital {
  width: 1200px;
  margin: auto;
  text-align: center;
  }
.col-tital-main{
  font-size: 36px;
  font-weight: bold;
  font-family: "微软雅黑 ";
}
.col-tital-minor{
  font-size: 14px;
  font-family: "微软雅黑 Light";
  margin-top: 10px;
  margin-bottom: 40px;
  color: #aaaaaa;
}
  .col-con{
    width: 1200px;
    margin: auto;
    height: 360px;
    margin-bottom: 60px;
  }
  .col-con ul{
    list-style-type: none;
    float: left;
    margin-left: -25px;
  }
  .col-con li{
    box-sizing: inherit;
    width: 540px;
    line-height: 30px;
    font-size: 16px;
    color: #333333;
    border-bottom: 1px #cccccc dashed;
    margin-bottom: 15px;
  }
      .col-con-left{
    float: left;
      width: 585px;
        margin-right: 15px;
        background: #ffffff;
        padding: 5px;
  }
    .col-con-left-tital{
    float: left;
      width: 575px;
      margin: 15px;
  }
  .col-con-left-tital-main{
    float: left;
    font-size: 20px;
    font-family: "微软雅黑 ";
    font-weight: bold;
    line-height: 24px;
  }
    .col-con-left-tital-min{
      font-family: "微软雅黑 ";
    float: right;
      font-size: 14px;
      color: #888888;
      line-height: 24px;
      margin-right: 30px;
  }
  .col-con-right{
        float: right;
      width: 585px;
        margin-left: 15px;
    background: #ffffff;
     padding: 5px;
  }
  .col-con-tital-tiao{
    float: left;
        border-style: none;
    width: 5px;
    height: 24px;
    margin-right: 8px;
  }
  .col-con-li-title{
    width: 450px;
    float: left;
        overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    margin-right: 20px;
    color: #333333;
  }
  .col-con-li-title-r{
    float: right;
  }
  .col-com-li-time{
    font-size: 14px;
    color:#888888;
    margin-bottom: 10px;
  }
  .col-con-ser-img {
    display: flex;
    /*background: #ffffff;*/
    /*height: 200px;*/
  }
  .col-con-ser-img img{
    width: 210px;
    height: 112px;
    margin: 15px;
  }
  .col-yqlj img{
    margin: 20px 0px 20px 45px;
    width: 240px;
    height: 95px;
  }
</style>
